#!/bin/sh
set -eu

dir=$(dirname "$0")

if test -z "${docker:=$(which podman || which docker || true)}"; then
  echo 'Neither podman nor docker are installed'
  exit 1
fi

if [ -z "${1:-}" ] || [ "${1:-}" = amd64 ]; then
    $docker build --build-arg debian_arch=amd64 --build-arg personality=linux64 -t ghcr.io/cockpit-project/unit-tests ${dir}
fi

if [ -z "${1:-}" ] || [ "${1:-}" = i386 ]; then
    $docker build --build-arg debian_arch=i386 --build-arg personality=linux32 -t ghcr.io/cockpit-project/unit-tests:i386 ${dir}
fi
